﻿using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        private sqlHerper SqlHerper = new sqlHerper();
        protected void Page_Load(object sender, EventArgs e)
        {
            Literal1.Text = "<a href='WebForm2.aspx'>点击去注册</a>";
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string sql = "select * from StudentInfo where stu_name=@name and password=@pwd";
            SqlParameter[] pars =
            {
                new SqlParameter("@name",TextBox1.Text),
                new SqlParameter ("@pwd",TextBox2.Text)
            };
            DataTable dt = SqlHerper.Get(sql,pars);
            if (dt.Rows.Count>0)//如果返回的记录条数大于0，就说明登录成功！
            {
                Session["username"] = TextBox1.Text;
                Response.Redirect("WebForm3.aspx");
            }
            else
            {
                Literal1.Text = "用户或密码错误！";
            }


        }
    }
}